package org.jiuling.appletofwechat.model;

/**
 * JS校验码转会话模型
 * @author 紫灵
 * @date 2024年01月28日 22时49分42秒
 */
public class JsCode2SessionModel {

    /** 会话密钥 */
    private String sessionKey;
    /** 用户在开放平台的唯一标识符，若当前小程序已绑定到微信开放平台账号下会返回，详见 UnionID 机制说明。 */
    private String unionId;
    /** 错误信息 */
    private String errMsg;
    /** 用户唯一标识 */
    private String openId;
    /** 错误码 */
    private Integer errCode;


    public String getSessionKey() {
        return sessionKey;
    }

    public String getUnionId() {
        return unionId;
    }

    public String getErrMsg() {
        return errMsg;
    }

    public String getOpenId() {
        return openId;
    }

    public int getErrCode() {
        return errCode;
    }

    /**
     * 建造者
     * @return 建造者
     */
    public static Builder builder(){
        return new Builder();
    }

    public static class Builder {
        private final JsCode2SessionModel jsCode2SessionModel;

        private Builder() {
            this.jsCode2SessionModel = new JsCode2SessionModel();
        }


        public Builder addSessionKey(String sessionKey) {
            jsCode2SessionModel.sessionKey = sessionKey;
            return this;
        }

        public Builder addUnionId(String unionId) {
            jsCode2SessionModel.unionId = unionId;
            return this;
        }

        public Builder addErrMsg(String errMsg) {
            jsCode2SessionModel.errMsg = errMsg;
            return this;
        }

        public Builder addOpenId(String openId) {
            jsCode2SessionModel.openId = openId;
            return this;
        }

        public Builder addErrCode(Integer errCode) {
            jsCode2SessionModel.errCode = errCode;
            return this;
        }

        public JsCode2SessionModel build() {
            return jsCode2SessionModel;
        }
    }
}
